#!/usr/bin/bash
set -e
mkdir -p /opt/tmp/


name="jdk1.8"
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u141-b15/336fa29ff2bb4ef291e347e091f7f4a7/jdk-8u141-linux-x64.tar.gz" -O ${name}.tar.gz
mkdir /opt/${name} && tar -zxvf ${name}.tar.gz -C  /opt/${name}  --strip-components 1
echo -e "export JAVA_HOME=/opt/${name}\nexport PATH=\$JAVA_HOME/bin:\$PATH">>/etc/profile
mv jdk1.8.tar.gz /opt/tmp
